package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.GiftRecordsMapper;
import com.ruoyi.system.domain.GiftRecords;
import com.ruoyi.system.service.IGiftRecordsService;

/**
 * 礼金明细Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-08-11
 */
@Service
public class GiftRecordsServiceImpl implements IGiftRecordsService 
{
    @Autowired
    private GiftRecordsMapper giftRecordsMapper;

    /**
     * 查询礼金明细
     * 
     * @param id 礼金明细主键
     * @return 礼金明细
     */
    @Override
    public GiftRecords selectGiftRecordsById(Integer id)
    {
        return giftRecordsMapper.selectGiftRecordsById(id);
    }

    /**
     * 查询礼金明细列表
     * 
     * @param giftRecords 礼金明细
     * @return 礼金明细
     */
    @Override
    public List<GiftRecords> selectGiftRecordsList(GiftRecords giftRecords)
    {
        return giftRecordsMapper.selectGiftRecordsList(giftRecords);
    }

    /**
     * 新增礼金明细
     * 
     * @param giftRecords 礼金明细
     * @return 结果
     */
    @Override
    public int insertGiftRecords(GiftRecords giftRecords)
    {
        Integer bookId = giftRecords.getBookId();
        int count = giftRecordsMapper.countRecordByBookId(bookId);
        giftRecords.setBookSeq(count + 1);
        giftRecords.setCreateTime(DateUtils.getNowDate());
        return giftRecordsMapper.insertGiftRecords(giftRecords);
    }

    /**
     * 修改礼金明细
     * 
     * @param giftRecords 礼金明细
     * @return 结果
     */
    @Override
    public int updateGiftRecords(GiftRecords giftRecords)
    {
        giftRecords.setUpdateTime(DateUtils.getNowDate());
        return giftRecordsMapper.updateGiftRecords(giftRecords);
    }

    /**
     * 批量删除礼金明细
     * 
     * @param ids 需要删除的礼金明细主键
     * @return 结果
     */
    @Override
    public int deleteGiftRecordsByIds(Integer[] ids)
    {
        return giftRecordsMapper.deleteGiftRecordsByIds(ids);
    }

    /**
     * 删除礼金明细信息
     * 
     * @param id 礼金明细主键
     * @return 结果
     */
    @Override
    public int deleteGiftRecordsById(Integer id)
    {
        return giftRecordsMapper.deleteGiftRecordsById(id);
    }
}
